<!-- 薪资排行 -->
<template>
	<view class="page">
		<u-navbar title="自我介绍">
		</u-navbar>
		<view class="form-box">
			<u-form :model="form" ref="uForm">
				<u-input border-color="#303133" height="200" type="textarea" border maxlength="20" v-model="form.introduce" :showWordLimit="true"/>
			</u-form>
			<view class="tip-box">
				<view class="tip-info">*让大家了解你多一点</view>
			</view>
		</view>
		<view class="btn-box">
			<view class="btn" @click="save" :class="[form.introduce=='' ? 'btn-disabled' : 'btn-primary']">保存</view>
		</view>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	import {mapState} from 'vuex';
	export default {
		data() {
			return {
				disabled: false,
				form: {
					introduce: '',
				},
			}
		},
		onLoad() {
			this.getUserInfo();
		},
		computed: {
			...mapState(['vuex_user']),
		},
		methods: {
			getUserInfo() {
				this.$u.get('/system/user/getInfo').then(res => {
					var user = res.user;
					if(user.introduce == null){
						user.introduce = '';
					}
					this.form.introduce = user.introduce;
				})
			},
			save() {
				if(this.form.introduce != ''){
					this.$u.put('/system/user/profile',{
						introduce: this.form.introduce
					}).then(res => {
						var user = this.vuex_user;
						user.introduce = this.form.introduce;
						this.$store.commit('setUser', user);
						uni.navigateBack({ //返回
							delta: 1
						});
					})
				}
			},
		},
	}
</script>

<style lang="scss">
	page {
		background-color: #F8F8F8;
	}
	.form-box {
		padding: 0px 15px;
		padding-top: 15px;
	}
	.tip-box {
		margin-top: 20px;
	}
	.tip-info {
		font-size: 30rpx;
		color: #82848a;
	}
	.btn-box {
		display: flex;
		padding: 15px;
		margin-top: 20px;
	}
	.btn {
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: center;
		padding: 10px;
		font-size: 32rpx;
		color: #fff;
		border-radius: 10rpx;
	}
	.btn-disabled {
		background-color: #ddd;
	}
	.btn-primary {
		background-color: #2979ff;
	}
</style>
